<?PHP
	if(isset($this->request->data['nb'])) {
		$nb = $this->request->data['nb'];
		$services = $this->Site->questions_a_afficher();
	}
?>
<div class="formentier">
	
	<div class="topform">
		<div class="choix_services">
	<?PHP
		/* creation des checkbox pour les services */
		foreach($services as $service):
			echo '<div class="service">';
			echo $this->Form->label($service['info_VoxBloc']['libelle_vox_bloc'], $service['info_VoxBloc']['libelle_vox_bloc']);
			echo $this->Form->checkbox($service['info_VoxBloc']['libelle_vox_bloc'], array('id' => "checkbox_".$nb."_".$service['info_VoxBloc']['id_vox_bloc'], 'onclick' => "toggleAffichageBloc(this.id);"));
			echo "</div>";
		endforeach;
	?>
		</div>
		<div class="infossite">
<?PHP
	echo $this->Form->input("Site.$nb.nom_site", array('label' => 'Nom du site :', 'error' => array('attributes' => array('id' => "ErrorSite".$nb."nom_site"))));
	if(!$this->Form->isFieldError("Site.$nb.nom_site"))
		echo '<div class="error-message" style="display:none" id="ErrorSite'.$nb.'nom_site"></div>';

	echo $this->Form->input("Site.$nb.adresse_site", array('label' => 'Adresse :', 'type' => 'text', 'error' => array('attributes' => array('id' => "ErrorSite".$nb."adresse_site"))));
	if(!$this->Form->isFieldError("Site.$nb.adresse_site"))
		echo '<div class="error-message" style="display:none" id="ErrorSite'.$nb.'adresse_site"></div>';

	echo $this->Form->input("Site.$nb.code_postal_site", array('label' => 'Code postal :', 'error' => array('attributes' => array('id' => "ErrorSite".$nb."code_postal_site"))));
	if(!$this->Form->isFieldError("Site.$nb.code_postal_site"))
		echo '<div class="error-message" style="display:none" id="ErrorSite'.$nb.'code_postal_site"></div>';

	echo $this->Form->input("Site.$nb.ville_site", array('label' => 'Ville :', 'error' => array('attributes' => array('id' => "ErrorSite".$nb."ville_site"))));
	if(!$this->Form->isFieldError("Site.$nb.ville_site"))
		echo '<div class="error-message" style="display:none" id="ErrorSite'.$nb.'ville_site"></div>';

	echo $this->Form->input("Site.$nb.telephone_site", array('label' => 'Téléphone :', 'error' => array('attributes' => array('id' => "ErrorSite".$nb."telephone_site"))));
	if(!$this->Form->isFieldError("Site.$nb.telephone_site"))
		echo '<div class="error-message" style="display:none" id="ErrorSite'.$nb.'telephone_site"></div>';

	echo $this->Form->input("Site.$nb.fax_site", array('label' => 'Fax :', 'error' => array('attributes' => array('id' => "ErrorSite".$nb."fax_site"))));
	if(!$this->Form->isFieldError("Site.$nb.fax_site"))
		echo '<div class="error-message" style="display:none" id="ErrorSite'.$nb.'fax_site"></div>';
?>
		</div>
	</div>
<?PHP
echo '<div style="clear:both; padding:1px;"></div>';
	foreach($services as $service) {
	/* parcours les vox_bloc (services) */
		echo '<div style="display:none;" id="bloc_'.$nb.'_'.$service['info_VoxBloc']['id_vox_bloc'].'">';
		echo '<div class="titre_clic">'.$service['info_VoxBloc']['libelle_vox_bloc'].' - '.$service['info_VoxBloc']['id_vox_bloc'].'</div>';
		echo '<div class="togglebox">';
		foreach($service['BlocsQuestions'] as $bloc) {
		/* parcours les bloc_questions du vox_bloc courant */
			echo '<div class="form_categorie">';
			echo '<div class="titre_categorie">'.$bloc['info_BlocQuestion']['description_bloc'].'</div>';
			echo count($bloc['Questions']).'<br />';
			foreach($bloc['Questions'] as $question) {
			/* parcours les questions du bloc_question courant */
				echo $question['type_reponse'];
				switch($question['type_reponse']) {
					case 'LISTE':
						echo $this->element('form_liste', array("question" => $question, "nb"=> $nb, "questionscombos" => $questionscombos));
						break;
					case 'ARTICLE':
						echo $this->element('form_article', array("question" => $question, "nb"=> $nb, "questionsavecarticles" => $questionsavecarticles));
						break;
					case 'OUINON':
						echo $this->element('form_ouinon', array("question" => $question, "nb"=> $nb));
						break;
					case 'ENTIER': 
						echo $this->element('form_entier', array("question" => $question, "nb"=> $nb));
						break;
					case 'TEXTE': 
						echo $this->element('form_texte', array("question" => $question, "nb"=> $nb));
						break;
					default:
						break;
				}
			}
			echo '</div>';
		}
		echo '</div>';
		echo '</div>';
	}
?>

</div>